import listCell from '@/components/mix-list-cell';
import { userInfo } from '@/api/user.js';
import { formatDate } from '@/utils/date';

export default {
	components: {
		listCell
	},
	data() {
		return {
			info:{
				avatar:"",
				userName: "",
				sex: "",
				phone: "",
				email: "",
				birthday: "",
				city: "",
				sign: "",
			}
		};
	},
	onShow() {
		this.loadData();
	},
	methods: {
		loadData() {
			userInfo().then(response => {
				let data = response.data;

				if(data!=null){
					//性别
					if(data.sex==null){
						data.sex = "未知"
					}else if(data.sex == 1){
						data.sex = "男"
					}else if(data.sex == 2){
						data.sex = "女"
					}else{
						data.sex = "未知"
					}
					//出生日期
					if(data.birthday==null){
						data.birthday = "未知";
					}else{
						let birthday = new Date(data.birthday);
						data.birthday = formatDate(birthday, 'yyyy-MM-dd')
					}
				}
				this.info = data;
			});
		},
	},
}